<template>
  <VabDrawer v-model="isShowDialog" :close-on-click-modal="true" show-fullscreen title="系统参数" width="30%">
    <CommonForm ref="commonFormRef" v-model="form" :layout-config="layoutConfig" :option="option" @on-cancel="handleClose">
    </CommonForm>
    <template #footer>
      <el-button @click="handleClose">取 消</el-button>
    </template>
  </VabDrawer>
</template>

<script>
import CommonForm from "@/plugins/form/CommonForm.vue";
import VabDrawer from "@/plugins/VabDialog/drawerModule.vue";
import { TableColumnOrFormTypeEnum } from "@/plugins/commonType.enum";

export default defineComponent({
  name: "UserInfo",
  components: {
    CommonForm,
    VabDrawer
  },
  props: {},
  emits: { "on-success": null },

  setup(props, { expose }) {
    /**
     * form组件布局
     */
    const layoutConfig = reactive({
      column: 1
    });

    const isShowDialog = ref(false);
    const form = ref({});

    const option = {
      column: [
        {
          label: "参数名称",
          prop: "configName",
          type: TableColumnOrFormTypeEnum.INPUT
        },
        {
          label: "参数编码",
          prop: "configKey",
          type: TableColumnOrFormTypeEnum.INPUT
        },
        {
          label: "参数类型",
          prop: "configType",
          type: TableColumnOrFormTypeEnum.SELECT,
          dictCode: "SysParamType"
        },
        {
          label: "参数值",
          type: TableColumnOrFormTypeEnum.INPUT,
          prop: "configValue"
        },
        {
          label: "参数描述",
          prop: "memo",
          type: TableColumnOrFormTypeEnum.TEXTAREA,
          placeholder: "请输入参数描述"
        }
      ],
      formConfig: {
        // title: '基本信息',
        disabled: true,
        isInModal: true
      },
      btnsConfig: {
        save: {
          isShow: false
        },
        back: {
          isShow: false
        }
      },
      rules: {}
    };
    const showDialog = row => {
      if (row) {
        form.value = row;
      } else {
        form.value = {};
      }
      isShowDialog.value = true;
    };

    const handleClose = () => {
      isShowDialog.value = false;
    };

    expose({ showDialog });
    return {
      isShowDialog,
      form,
      option,
      layoutConfig,
      handleClose
    };
  }
});
</script>

<style lang="scss" scoped></style>
